Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health status worker metrics improvements #10442

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

ehconitin
Copy link
Contributor

No description provided.

@ehconitin ehconitin force-pushed the health-status-worker-metrics-improvements branch from b322619 to 67808e6 Compare February 24, 2025 20:05
@ehconitin ehconitin marked this pull request as ready for review February 25, 2025 13:43
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR enhances worker metrics visualization in the admin panel health status section, adding time-series graphs and improving loading states.

  • Added new WorkerMetricsGraph component in health-status/components/WorkerMetricsGraph.tsx that displays queue performance metrics over time with interactive time range selection
  • Added getQueueMetrics GraphQL query in health-status/graphql/queries/getQueueMetrics.ts to fetch time-series metrics data for worker queues
  • Enhanced server-side metrics collection in admin-panel-health.service.ts with support for different time ranges (4H, 12H, 1D, 7D)
  • Added proper loading states with new SettingsAdminTabSkeletonLoader component for better UX during data fetching
  • Improved queue health button styling with hover effects in SettingsAdminQueueHealthButtons.tsx

Greptile: I've analyzed the changes in this PR which focuses on enhancing the worker metrics visualization and health status monitoring in the admin panel.

22 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +33 to 35
`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Unnecessary whitespace in the template literal.

Comment on lines +307 to +347
it('should return metrics data for a queue', async () => {
const mockCompletedMetrics = { data: [10, 20, 30] };
const mockFailedMetrics = { data: [1, 2, 3] };

mockQueue.getMetrics
.mockResolvedValueOnce(mockCompletedMetrics)
.mockResolvedValueOnce(mockFailedMetrics);

workerHealth.getQueueDetails.mockResolvedValue({
queueName: 'test-queue',
workers: 1,
status: 'up',
metrics: {
active: 1,
completed: 30,
failed: 3,
waiting: 0,
delayed: 0,
failureRate: 9.1,
},
});

const result = await service.getQueueMetricsOverTime(
MessageQueue.messagingQueue,
'4H',
);

expect(result).toMatchObject({
queueName: MessageQueue.messagingQueue,
timeRange: '4H',
data: expect.arrayContaining([
expect.objectContaining({
id: 'Completed Jobs',
data: expect.any(Array),
}),
expect.objectContaining({
id: 'Failed Jobs',
data: expect.any(Array),
}),
]),
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The test verifies the structure of the result but doesn't validate the actual data transformation logic. Consider adding assertions to verify that the metrics data from the mock is correctly transformed into the expected time series format.

Comment on lines +350 to +365
it('should handle empty metrics data', async () => {
mockQueue.getMetrics
.mockResolvedValueOnce({ data: [] })
.mockResolvedValueOnce({ data: [] });

workerHealth.getQueueDetails.mockResolvedValue(null);

const result = await service.getQueueMetricsOverTime(
MessageQueue.messagingQueue,
'4H',
);

expect(result.data).toHaveLength(2);
expect(result.data[0].data).toHaveLength(48); // Default points for 4H
expect(result.data[1].data).toHaveLength(48);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Test confirms the array lengths but doesn't verify the timestamps are correctly generated. Consider adding assertions to check the timestamp values match the expected pattern for the 4H timeframe.

Comment on lines +97 to +101
workers.length > 0
? failureRate > METRICS_FAILURE_RATE_THRESHOLD
? 'down'
: 'up'
: 'down',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Redundant condition check. Line 97 checks workers.length > 0 but we're already inside a block (line 64) that only executes when workers.length > 0.

this.logger.error(
`Error getting queue details for ${queueName}: ${error.message}`,
);
await queue.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Queue close attempt after error might not execute if the error happens during queue.close() itself. Consider using try/finally to ensure cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants